import br.com.nooclix.salon.ui.util.ResponseData;
import br.com.nooclix.salon.ui.util.WindowsMessage;

import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

public function persistResult(event:ResultEvent):void{
	var responseData:ResponseData = event.result as ResponseData;
	if(responseData.status == ResponseData.ok()){
		WindowsMessage.confirm("Funcionário salvo com sucesso!");
		if(bySearch){
			findByName();
			this.currentState = "search";
		}
		personView.clearFields();
	}else{
		WindowsMessage.alarm(responseData.message);
		
	}
}

public function removeResult(event:ResultEvent):void{
	
	var responseData:ResponseData = event.result as ResponseData;
	
	if(responseData.status == ResponseData.ok()){
		findByName();
	}else{
		WindowsMessage.alarm(responseData.message);
	}
}

public function updateResult(event:ResultEvent):void{
	
	var responseData:ResponseData = event.result as ResponseData;
	
	if(responseData.status == ResponseData.ok()){
		WindowsMessage.confirm("Funcionário atualizado(a) com sucesso!");
	}else{
		WindowsMessage.alarm(responseData.message);
	}
}


public function findByNameResult(event:ResultEvent):void{
	var responseData:ResponseData = event.result as ResponseData;
	
	if(responseData.status == ResponseData.ok()){
		gridEmployee.dataProvider = responseData.items;
	}else{
		WindowsMessage.alarm(responseData.message);
	}
}